home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Audio / Patchmix / Source / Out.m < prev    next >
Text File  |  1992-07-31  |  2KB  |  126 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "Out.h"
  5. #import "Instrum.h"
  6. #import "Statement.h"
  7.  
  8. @implementation Out
  9.  
  10. + initialize
  11. {
  12.        image = [NXImage findImageNamed:"Out"];
  13.     outOffset.x = 25;
  14.     outOffset.y = 50;
  15.     return self;
  16. }
  17.  
  18. - init
  19. {
  20.     written = NO;
  21.     size.width = 80.;
  22.     size.height = 80.;
  23.     center.x = size.width/2.;
  24.     center.y = size.height/2.;
  25.     strcpy(type,"Out");
  26.     
  27.     out = [[Param alloc] init:self :&outOffset];
  28.     [out setTitle:"Out:"];
  29.  
  30.     paramList = [[List alloc] initCount:1];
  31.     [paramList addObject:out];
  32.  
  33.     [Inst putUgenInList:self];
  34.     return self;
  35. }
  36.  
  37. - remove
  38. {
  39.     id cp,param;
  40.     int i;
  41.                             // make sure not connected first 
  42.     for(i = 0; i < ([paramList count]); i++) {    
  43.         param = [paramList objectAt:i];
  44.         if(cp = [param getConnectedParam]) 
  45.             return 0;
  46.     }
  47.                             // remove ugen from list
  48.     [Inst removeUgenFromList:self];
  49.     return self;
  50. }
  51.  
  52.  
  53. - (NXImage *)getImage
  54. {
  55.     return image;
  56. }
  57.  
  58. - move:(NXPoint *)newloc
  59. {
  60.     location = *newloc;
  61.     [out move:&location];
  62.     return self;
  63. }
  64.  
  65. - findParamAtPoint:(NXPoint *)point
  66. {
  67.     NXRect *rect;
  68.     int i;
  69.     id param;
  70.     
  71.     for(i = 0; i < [paramList count]; i++) {
  72.         param = [paramList objectAt:i];
  73.         rect = [param getRect];
  74.         if(NXMouseInRect(point,rect,NO))
  75.             return param;
  76.     }
  77.     //printf("no param found\n");
  78.     return nil;
  79. }
  80.  
  81. - findCornerUgen
  82. {
  83.     id par = nil;
  84.     id nupar = nil;
  85.  
  86.     //printf("%s\n",type);    
  87.     par = [paramList objectAt:0];
  88.     if(nupar = [par getConnectedParam])        // if there is an upper 
  89.         [[nupar getUgen] findCornerUgen];    // left ugen, continue looking
  90.     else 
  91.         return self;            
  92. }
  93.  
  94. - writeUgen
  95. {
  96.     int i;
  97.     id param;
  98.     id ug;
  99.     id nupar;
  100.     char str[50];
  101.     int parent;
  102.     
  103.     //printf("writing out %d\n",index);
  104.     sprintf(str,"\tfloat ug%d;\n",index);
  105.     [Inst putVarInList:str];
  106.  
  107.     for(i = 0; i < [paramList count]; i++) {    
  108.         param = [paramList objectAt:i];
  109.         if(nupar = [param getConnectedParam]) {
  110.             ug = [nupar getUgen];
  111.             if([ug getWritten] == NO) 
  112.                 parent = [[ug writeUgen] getIndex];
  113.         }
  114.     }
  115.     sprintf(str, "\t\tout[0] = ug%d;\n",parent);
  116.     [Inst putLoopInList:str];
  117.     sprintf(str,"\t\tif (chans > 1) {\n");
  118.     [Inst putLoopInList:str];
  119.     sprintf(str,"\t\t\tout[1] = out[0];\n\t\t}\n");
  120.     [Inst putLoopInList:str];
  121.     
  122.     return self;
  123. }
  124.  
  125. @end
  126.